import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';

import '../utils/lang/intl_base.dart';
import '../utils/lang/translations_service.dart';
import '../widgets/yh_smart_dialog.dart';

/// 在文件顶层声明，整个应用都能访问
/// late 语法 - 只能赋值一次
/// 全局作用域 - 整个应用共享同一个变量
/// 启动时初始化 - 在应用启动时创建实例并赋值
/// 之后只读访问 - 全应用都访问这个唯一实例
/// 这就是一个经典的全局单例模式！ 🎯
late CoreConfig appGlobalConfig;




class CoreConfig {
  CoreConfig({required this.appConfig, required this.netWorkConfig, required this.intlConfig, required this.widgetConfig, required this.dialogConfig});
  final AppConfig appConfig;
  final NetWorkConfig netWorkConfig;
  final IntlConfig intlConfig;
  final WidgetConfig widgetConfig;
  final DialogConfig dialogConfig;
}

abstract class AppConfig {
  String get initRouter;
  List<GetPage<dynamic>>? get getPages;
  ThemeData get theme;
  bool get isDebug;
  bool get isDarkStatusBar;
}

abstract class NetWorkConfig {
  String get baseUrl;
  Map<String, String> get headers;
  Duration get connectTimeout;
  Duration get receiveTimeout;

  // // 请求配置工厂方法
  //   NetConfig<D, S> Function<D, S>({
  //   required String url,
  //   required NetMethod method,
  //   NetHandler<D, S>? netHandle,
  //   Map<String, dynamic>? params,
  //   Options? options,
  //   dynamic data,
  //   ProgressCallback? onSendProgress,
  //   ProgressCallback? onReceiveProgress,
  //   CancelToken? cancelToken,
  //   }) get creator;
}

abstract class IntlConfig {
  LanguageType get initLanguage;
  List<LanguageType> get supportLanguages;
  List<List<IntlBase>> get intlValues;
}

/// 组件配置类 - 管理通用UI组件样式
abstract class WidgetConfig {
  /// 导航栏样式 - 必须实现
  Widget get backIcon;
  Color get navBackgroundColor;
  TextStyle get navTitleStyle;
  Color get indicatorColor;

  /// 输入框样式 - 必须实现
  TextStyle get textFieldTextStyle;
  TextStyle get textFieldHintStyle;

  /// 通用颜色（可选实现）
  Color get transparentColor => Colors.transparent;
}

/// 对话框配置类 - 管理 flutter_smart_dialog 相关配置
abstract class DialogConfig {

  /// 当前消息类型状态
  MsgType currentMsgType = MsgType.normal;

  /// 对话框按钮颜色（可选实现）
  Color get confirmBtnColor => const Color(0xFF2B5CFF);
  Color get warningBtnColor => const Color(0xFFFF9800);
  Color get errorBtnColor => const Color(0xFFF5222D);
  Color get buttonTextColor => Colors.white;

  /// 对话框样式（可选实现）
  Color get cardBackgroundColor => Colors.white;
  TextStyle get dialogTitleStyle => const TextStyle(fontSize: 17, fontWeight: FontWeight.bold, color: Colors.black);
  TextStyle get dialogContentStyle => const TextStyle(fontSize: 15, color: Colors.black87);

  /// 遮罩和分割线颜色（可选实现）
  Color get dialogMaskColor => Colors.black.withOpacity(0.2);
  Color get dividerColor => const Color(0xFFEEEEEE);

  /// 全局 Loading Widget 构建器
  Widget loadingWidget(String msg);

  /// 全局 Toast Widget 构建器
  Widget toastWidget(String msg);

  /// 全局 Notify 样式
  FlutterSmartNotifyStyle get notifyStyle;
}
